﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PartitionsCodegen
{
    class Generator
    {
        public bool generate(bool clipboard)
        {
            int copies = Program.getCopies();
            float[] depths = Program.getDepths();
            decimal offset_x = Program.getOffsetX();
            decimal offset_y = Program.getOffsetY();
            bool to_the_right = Program.getToTheRight();
            String s_code = Program.getCode();

            CNCCode code = new CNCCode(s_code,copies,depths,offset_x,offset_y,to_the_right);
            String s_codeAll = code.getString().Replace(",", ".");
            Console.WriteLine("---------------------------Result code------------------");
            Console.WriteLine(s_codeAll);
            
            if(clipboard)
            System.Windows.Forms.Clipboard.SetText(s_codeAll);

            else {
                string f_name = "output.txt";//DateTime.Now.ToString("yyyy-MM-_HH.mm.ss")+".txt";
                System.IO.File.WriteAllText(f_name, s_codeAll);
                System.Diagnostics.Process.Start(f_name);
            }
            return true;
        }
    }
}
